Generation of bokeh images using adaptive focus range and layered scattering

ABSTRACT

A method includes determining, using at least one processor, a depth of range of focus for a scene. The method also includes determining, using the at least one processor, multiple layers associated with the scene based on the depth of focus range, where each layer is associated with image data having a different range of disparity values. The method further includes blending, using the at least one processor, the layers to produce an image having a Bokeh effect in a foreground and a background, and focused image data within the depth of focus range. The multiple layers include at least a first layer associated with the foreground, a second layer associated with the depth of focus range, and a third layer associated with the background.

TECHNICAL FIELD

This disclosure relates generally to image capturing systems. Morespecifically, this disclosure relates to the generation of Bokeh imagesusing an adaptive focus range and layered scattering.

BACKGROUND

Many mobile electronic devices, such as smartphones and tabletcomputers, include cameras that can be used to capture still and videoimages. While convenient, cameras on mobile electronic devices typicallyhave short focal lengths and small aperture sizes, so pictures taken ona mobile electronic device are usually sharp. As a result, it is hard tocreate artistic effects such as “Bokeh” in captured images unless asubject in a scene is very close to the mobile electronic device.

“Bokeh” refers to an effect that helps to improve the aesthetic qualityof an image by blurring out-of-focus portions of the image (such as abackground of the image) while keeping other portions of the image (suchas a foreground or one or more subjects) in focus. For many mobileelectronic devices, Bokeh is achieved computationally rather thanoptically. For example, a mobile electronic device may estimate variousdepths in a scene, and Bokeh images of the scene can be createdcomputationally using the estimated depths.

SUMMARY

This disclosure relates to the generation of Bokeh images using anadaptive focus range and layered scattering.

In a first embodiment, a method includes determining, using at least oneprocessor, a depth of range of focus for a scene. The method alsoincludes determining, using the at least one processor, multiple layersassociated with the scene based on the depth of focus range, where eachlayer is associated with image data having a different range ofdisparity values. The method further includes blending, using the atleast one processor, the layers to produce an image having a Bokeheffect in a foreground and a background, and focused image data withinthe depth of focus range. The multiple layers include at least a firstlayer associated with the foreground, a second layer associated with thedepth of focus range, and a third layer associated with the background.

In a second embodiment, an electronic device includes multiple imagesensors configured to capture image data for a scene and at least oneprocessor operatively connected to the image sensors. The at least oneprocessor is configured to determine a depth of focus range for thescene. The at least one processor is also configured to determinemultiple layers associated with the scene based on the depth of focusrange, where each layer is associated with image data having a differentrange of disparity values. The at least one processor is furtherconfigured to produce an image having a Bokeh effect in a foreground anda background, and focused image data within the depth of focus range.The multiple layers include at least a first layer associated with theforeground, a second layer associated with the depth of focus range, anda third layer associated with the background.

In a third embodiment, a non-transitory machine-readable medium containsinstructions that when executed cause at least one processor of anelectronic device to determine a depth of focus range for the scene. Themedium also contains instructions that when executed cause the at leastone processor to determine multiple layers associated with the scenebased on the depth of focus range. Each layer is associated with imagedata having a different range of disparity values. The medium furthercontains instructions that when executed cause the at least oneprocessor to produce an image having a Bokeh effect in a foreground anda background, and focused image data within the depth of focus range.The multiple layers include at least a first layer associated with theforeground, a second layer associated with the depth of focus range, anda third layer associated with the background.

In a fourth embodiment, a method includes determining, using at leastone processor, a focus position in a scene based on an input touchpoint. The method also includes initializing, using the at least oneprocessor, a depth of focus range related to the input touch point. Themethod further includes generating, using the at least one processor, animage preview based on the initial depth of focus range, where the imagepreview is focused within the initial depth of focus range and blurryoutside the initial depth of focus range.

Other technical features may be readily apparent to one skilled in theart from the following figures, descriptions, and claims.

Before undertaking the DETAILED DESCRIPTION below, it may beadvantageous to set forth definitions of certain words and phrases usedthroughout this patent document. The terms “transmit,” “receive,” and“communicate,” as well as derivatives thereof, encompass both direct andindirect communication. The terms “include” and “comprise,” as well asderivatives thereof, mean inclusion without limitation. The term “or” isinclusive, meaning and/or. The phrase “associated with,” as well asderivatives thereof, means to include, be included within, interconnectwith, contain, be contained within, connect to or with, couple to orwith, be communicable with, cooperate with, interleave, juxtapose, beproximate to, be bound to or with, have, have a property of, have arelationship to or with, or the like.

Moreover, various functions described below can be implemented orsupported by one or more computer programs, each of which is formed fromcomputer readable program code and embodied in a computer readablemedium. The terms “application” and “program” refer to one or morecomputer programs, software components, sets of instructions,procedures, functions, objects, classes, instances, related data, or aportion thereof adapted for implementation in a suitable computerreadable program code. The phrase “computer readable program code”includes any type of computer code, including source code, object code,and executable code. The phrase “computer readable medium” includes anytype of medium capable of being accessed by a computer, such as readonly memory (ROM), random access memory (RAM), a hard disk drive, acompact disc (CD), a digital video disc (DVD), or any other type ofmemory. A “non-transitory” computer readable medium excludes wired,wireless, optical, or other communication links that transporttransitory electrical or other signals. A non-transitory computerreadable medium includes media where data can be permanently stored andmedia where data can be stored and later overwritten, such as arewritable optical disc or an erasable memory device.

As used here, terms and phrases such as “have,” “may have,” “include,”or “may include” a feature (like a number, function, operation, orcomponent such as a part) indicate the existence of the feature and donot exclude the existence of other features. Also, as used here, thephrases “A or B,” “at least one of A and/or B,” or “one or more of Aand/or B” may include all possible combinations of A and B. For example,“A or B,” “at least one of A and B,” and “at least one of A or B” mayindicate all of (1) including at least one A, (2) including at least oneB, or (3) including at least one A and at least one B. Further, as usedhere, the terms “first” and “second” may modify various componentsregardless of importance and do not limit the components. These termsare only used to distinguish one component from another. For example, afirst user device and a second user device may indicate different userdevices from each other, regardless of the order or importance of thedevices. A first component may be denoted a second component and viceversa without departing from the scope of this disclosure.

It will be understood that, when an element (such as a first element) isreferred to as being (operatively or communicatively) “coupled with/to”or “connected with/to” another element (such as a second element), itcan be coupled or connected with/to the other element directly or via athird element. In contrast, it will be understood that, when an element(such as a first element) is referred to as being “directly coupledwith/to” or “directly connected with/to” another element (such as asecond element), no other element (such as a third element) intervenesbetween the element and the other element.

As used here, the phrase “configured (or set) to” may be interchangeablyused with the phrases “suitable for,” “having the capacity to,”“designed to,” “adapted to,” “made to,” or “capable of” depending on thecircumstances. The phrase “configured (or set) to” does not essentiallymean “specifically designed in hardware to.” Rather, the phrase“configured to” may mean that a device can perform an operation togetherwith another device or parts. For example, the phrase “processorconfigured (or set) to perform A, B, and C” may mean a generic-purposeprocessor (such as a CPU or application processor) that may perform theoperations by executing one or more software programs stored in a memorydevice or a dedicated processor (such as an embedded processor) forperforming the operations.

The terms and phrases as used here are provided merely to describe someembodiments of this disclosure but not to limit the scope of otherembodiments of this disclosure. It is to be understood that the singularforms “a,” “an,” and “the” include plural references unless the contextclearly dictates otherwise. All terms and phrases, including technicaland scientific terms and phrases, used here have the same meanings ascommonly understood by one of ordinary skill in the art to which theembodiments of this disclosure belong. It will be further understoodthat terms and phrases, such as those defined in commonly-useddictionaries, should be interpreted as having a meaning that isconsistent with their meaning in the context of the relevant art andwill not be interpreted in an idealized or overly formal sense unlessexpressly so defined here. In some cases, the terms and phrases definedhere may be interpreted to exclude embodiments of this disclosure.

Examples of an “electronic device” in accordance with this disclosuremay include at least one of a smartphone, a tablet personal computer(PC), a mobile phone, a video phone, an e-book reader, a desktop PC, alaptop computer, a netbook computer, a workstation, a personal digitalassistant (PDA), a portable multimedia player (PMP), an MP3 player, amobile medical device, a camera, or a wearable device (such as smartglasses, a head-mounted device (HMD), electronic clothes, an electronicbracelet, an electronic necklace, an electronic accessory, an electronictattoo, a smart mirror, or a smart watch). Other examples of anelectronic device include a smart home appliance. Examples of the smarthome appliance may include at least one of a television, a digital videodisc (DVD) player, an audio player, a refrigerator, an air conditioner,a cleaner, an oven, a microwave oven, a washer, a drier, an air cleaner,a set-top box, a home automation control panel, a security controlpanel, a TV box (such as SAMSUNG HOMESYNC, APPLETV, or GOOGLE TV), asmart speaker or speaker with an integrated digital assistant (such asSAMSUNG GALAXY HOME, APPLE HOMEPOD, or AMAZON ECHO), a gaming console(such as an XBOX, PLAYSTATION, or NINTENDO), an electronic dictionary,an electronic key, a camcorder, or an electronic picture frame. Stillother examples of an electronic device include at least one of variousmedical devices (such as diverse portable medical measuring devices(like a blood sugar measuring device, a heartbeat measuring device, or abody temperature measuring device), a magnetic resource angiography(MRA) device, a magnetic resource imaging (MRI) device, a computedtomography (CT) device, an imaging device, or an ultrasonic device), anavigation device, a global positioning system (GPS) receiver, an eventdata recorder (EDR), a flight data recorder (1-DR), an automotiveinfotainment device, a sailing electronic device (such as a sailingnavigation device or a gyro compass), avionics, security devices,vehicular head units, industrial or home robots, automatic tellermachines (ATMs), point of sales (POS) devices, or Internet of Things(IoT) devices (such as a bulb, various sensors, electric or gas meter,sprinkler, fire alarm, thermostat, street light, toaster, fitnessequipment, hot water tank, heater, or boiler). Other examples of anelectronic device include at least one part of a piece of furniture orbuilding/structure, an electronic board, an electronic signaturereceiving device, a projector, or various measurement devices (such asdevices for measuring water, electricity, gas, or electromagneticwaves). Note that, according to various embodiments of this disclosure,an electronic device may be one or a combination of the above-listeddevices. According to some embodiments of this disclosure, theelectronic device may be a flexible electronic device. The electronicdevice disclosed here is not limited to the above-listed devices and mayinclude new electronic devices depending on the development oftechnology.

In the following description, electronic devices are described withreference to the accompanying drawings, according to various embodimentsof this disclosure. As used here, the term “user” may denote a human oranother device (such as an artificial intelligent electronic device)using the electronic device.

Definitions for other certain words and phrases may be providedthroughout this patent document. Those of ordinary skill in the artshould understand that in many if not most instances, such definitionsapply to prior as well as future uses of such defined words and phrases.

None of the description in this application should be read as implyingthat any particular element, step, or function is an essential elementthat must be included in the claim scope. The scope of patented subjectmatter is defined only by the claims. Moreover, none of the claims isintended to invoke 35 U.S.C. § 112(f) unless the exact words “means for”are followed by a participle. Use of any other term, including withoutlimitation “mechanism,” “module,” “device,” “unit,” “component,”“element,” “member,” “apparatus,” “machine,” “system,” “processor,” or“controller,” within a claim is understood by the Applicant to refer tostructures known to those skilled in the relevant art and is notintended to invoke 35 U.S.C. § 112(f).

BRIEF DESCRIPTION OF THE DRAWINGS

For a more complete understanding of this disclosure and its advantages,reference is now made to the following description taken in conjunctionwith the accompanying drawings, in which like reference numeralsrepresent like parts:

FIG. 1 illustrates an example network configuration including anelectronic device in accordance with this disclosure;

FIG. 2 illustrates an example process for creating a Bokeh image usingan electronic device in accordance with this disclosure;

FIG. 3 illustrates an example process for applying computational Bokehto an image in accordance with this disclosure;

FIG. 4 illustrates an example user interface for receiving touch inputsthat define a depth of focus range in accordance with this disclosure;

FIG. 5 illustrates an example method of determining an adaptive focusrange in accordance with this disclosure;

FIG. 6 illustrates an example method of determining a circle ofconfusion (CoC) curve in accordance with this disclosure;

FIG. 7 illustrates an example conversion from depth space to disparityspace in accordance with this disclosure;

FIGS. 8A, 8B, 8C, and 8D illustrate an example multi-resolutiondisparity focus range refinement using a disparity histogram inaccordance with this disclosure;

FIGS. 9A and 9B illustrate an example comparison of CoC curves definedover a depth or disparity range in accordance with this disclosure;

FIG. 10 illustrates an example method of layer determination and layeredscattering in accordance with this disclosure;

FIG. 11 illustrates an example definition of multiple layers based on aCoC curve defined over disparity in accordance with this disclosure;

FIG. 12 illustrates an example kernel in accordance with thisdisclosure;

FIGS. 13 and 14 illustrate an example process for final composition of aBokeh image in accordance with this disclosure;

FIGS. 15A and 15B illustrate example alpha blending maps in accordancewith this disclosure;

FIG. 16 illustrates an example combination of image layers to create afinal Bokeh image in accordance with this disclosure; and

FIGS. 17A and 17B illustrate an example comparison of images inaccordance with this disclosure.

DETAILED DESCRIPTION

FIGS. 1 through 17B, discussed below, and the various embodiments ofthis disclosure are described with reference to the accompanyingdrawings. However, it should be appreciated that this disclosure is notlimited to these embodiments, and all changes and/or equivalents orreplacements thereto also belong to the scope of this disclosure. Thesame or similar reference denotations may be used to refer to the sameor similar elements throughout the specification and the drawings.

As noted above, cameras in many mobile electronic devices suffer fromvarious shortcomings related to image capture, such as short focallengths and small aperture sizes. As a result, it is hard to createartistic effects such as Bokeh in images captured using mobileelectronic devices. While computational Bokeh seeks to recreate theBokeh effect in images captured by mobile electronic devices,computational Bokeh does not always satisfy a user's intent regarding arange of focus in an image. In other words, the user cannot controlwhich objects appear blurry and which objects appear sharp in an imageusing computational Bokeh.

Often times, to produce the Bokeh effect using mobile electronicdevices, two or more cameras are used to estimate various depths in ascene, and a Bokeh image is computed using a sharp image of the sceneand its depth map. The depth map controls how much blur is applied toeach pixel of the sharp image according to the depth of thecorresponding pixel. Ideally, pixels forming the background of a sceneare blurred more, and pixels forming the foreground of the scene or oneor more targets of focus in the scene are blurred less. However, thereare various situations in which part of a target in a scene may be infocus while another part of a target is blurred, such as when the targetspans multiple depths in the scene.

This disclosure provides techniques for adaptive Bokeh based on a rangeof focus as defined by a user. For example, these techniques allow auser to define maximum and minimum depths of focus for a scene, such asby providing a graphical user interface having two sliding bars. Basedon the defined maximum and minimum depths of focus, these techniquesprocess image data to help ensure that the image data between themaximum and minimum depths of focus remain sharp while the other imagedata can be blurred. This can help to produce moreaesthetically-pleasing Bokeh images. Note that while this functionalityis often described below as being used in a mobile electronic device,this functionality may be used with any other suitable type ofelectronic device.

FIG. 1 illustrates an example network configuration 100 including anelectronic device in accordance with this disclosure. The embodiment ofthe network configuration 100 shown in FIG. 1 is for illustration only.Other embodiments of the network configuration 100 could be used withoutdeparting from the scope of this disclosure.

In accordance with this disclosure, an electronic device 101 is includedin the network configuration 100. The electronic device 101 can includeat least one of a bus 110, a processor 120, a memory 130, aninput/output (I/O) interface 150, a display 160, a communicationinterface 170, or a sensor 180. In some embodiments, the electronicdevice 101 may exclude at least one of these components or may add atleast one other component. The bus 110 includes a circuit for connectingthe components 120-180 with one another and for transferringcommunications (such as control messages and/or data) between thecomponents.

The processor 120 includes one or more of a central processing unit(CPU), an application processor (AP), or a communication processor (CP).The processor 120 is able to perform control on at least one of theother components of the electronic device 101 and/or perform anoperation or data processing relating to communication. In someembodiments, the processor 120 can be a graphics processor unit (GPU).Among other things, the processor 120 can receive image data captured byat least one imaging sensor and process the image data as discussed inmore detail below to produce images having improved Bokeh.

The memory 130 can include a volatile and/or non-volatile memory. Forexample, the memory 130 can store commands or data related to at leastone other component of the electronic device 101. In accordance withthis disclosure, the memory 130 can store software and/or a program 140.The program 140 includes, for example, a kernel 141, middleware 143, anapplication programming interface (API) 145, and/or an applicationprogram (or “application”) 147. At least a portion of the kernel 141,middleware 143, or API 145 may be denoted an operating system (OS).

The kernel 141 can control or manage system resources (such as the bus110, processor 120, or memory 130) used to perform operations orfunctions implemented in other programs (such as the middleware 143, API145, or application program 147). The kernel 141 provides an interfacethat allows the middleware 143, the API 145, or the application 147 toaccess the individual components of the electronic device 101 to controlor manage the system resources. The application 147 includes one or moreapplications for image capture and image processing as discussed below.These functions can be performed by a single application or by multipleapplications that each carries out one or more of these functions. Themiddleware 143 can function as a relay to allow the API 145 or theapplication 147 to communicate data with the kernel 141, for instance. Aplurality of applications 147 can be provided. The middleware 143 isable to control work requests received from the applications 147, suchas by allocating the priority of using the system resources of theelectronic device 101 (like the bus 110, the processor 120, or thememory 130) to at least one of the plurality of applications 147. TheAPI 145 is an interface allowing the application 147 to controlfunctions provided from the kernel 141 or the middleware 143. Forexample, the API 145 includes at least one interface or function (suchas a command) for filing control, window control, image processing, ortext control.

The I/O interface 150 serves as an interface that can, for example,transfer commands or data input from a user or other external devices toother component(s) of the electronic device 101. The I/O interface 150can also output commands or data received from other component(s) of theelectronic device 101 to the user or the other external device.

The display 160 includes, for example, a liquid crystal display (LCD), alight emitting diode (LED) display, an organic light emitting diode(OLED) display, a quantum-dot light emitting diode (QLED) display, amicroelectromechanical systems (MEMS) display, or an electronic paperdisplay. The display 160 can also be a depth-aware display, such as amulti-focal display. The display 160 is able to display, for example,various contents (such as text, images, videos, icons, or symbols) tothe user. The display 160 can include a touchscreen and may receive, forexample, a touch, gesture, proximity, or hovering input using anelectronic pen or a body portion of the user.

The communication interface 170, for example, is able to set upcommunication between the electronic device 101 and an externalelectronic device (such as a first electronic device 102, a secondelectronic device 104, or a server 106). For example, the communicationinterface 170 can be connected with a network 162 or 164 throughwireless or wired communication to communicate with the externalelectronic device. The communication interface 170 can be a wired orwireless transceiver or any other component for transmitting andreceiving signals, such as images.

The wireless communication is able to use at least one of, for example,long term evolution (LTE), long term evolution-advanced (LTE-A), 5thgeneration wireless system (5G), millimeter-wave or 60 GHz wirelesscommunication, Wireless USB, code division multiple access (CDMA),wideband code division multiple access (WCDMA), universal mobiletelecommunication system (UMTS), wireless broadband (WiBro), or globalsystem for mobile communication (GSM), as a cellular communicationprotocol. The wired connection can include, for example, at least one ofa universal serial bus (USB), high definition multimedia interface(HDMI), recommended standard 232 (RS-232), or plain old telephoneservice (POTS). The network 162 or 164 includes at least onecommunication network, such as a computer network (like a local areanetwork (LAN) or wide area network (WAN)), Internet, or a telephonenetwork.

The electronic device 101 further includes one or more sensors 180 thatcan meter a physical quantity or detect an activation state of theelectronic device 101 and convert metered or detected information intoan electrical signal. For example, one or more sensors 180 include oneor more cameras or other imaging sensors for capturing images of scenes.The sensor(s) 180 can also include one or more buttons for touch input,a gesture sensor, a gyroscope or gyro sensor, an air pressure sensor, amagnetic sensor or magnetometer, an acceleration sensor oraccelerometer, a grip sensor, a proximity sensor, a color sensor (suchas a red green blue (RGB) sensor), a bio-physical sensor, a temperaturesensor, a humidity sensor, an illumination sensor, an ultraviolet (UV)sensor, an electromyography (EMG) sensor, an electroencephalogram (EEG)sensor, an electrocardiogram (ECG) sensor, an infrared (IR) sensor, anultrasound sensor, an iris sensor, or a fingerprint sensor. Thesensor(s) 180 can further include an inertial measurement unit, whichcan include one or more accelerometers, gyroscopes, and othercomponents. In addition, the sensor(s) 180 can include a control circuitfor controlling at least one of the sensors included here. Any of thesesensor(s) 180 can be located within the electronic device 101. The oneor more cameras can capture images as discussed below and may be used inconjunction with at least one flash 190. The flash 190 represents adevice configured to generate illumination for use in image capture bythe electronic device 101, such as one or more LEDs.

The first external electronic device 102 or the second externalelectronic device 104 can be a wearable device or an electronicdevice-mountable wearable device (such as an HMD). When the electronicdevice 101 is mounted in the electronic device 102 (such as the HMD),the electronic device 101 can communicate with the electronic device 102through the communication interface 170. The electronic device 101 canbe directly connected with the electronic device 102 to communicate withthe electronic device 102 without involving with a separate network. Theelectronic device 101 can also be an augmented reality wearable device,such as eyeglasses, that include one or more cameras.

The first and second external electronic devices 102 and 104 and theserver 106 each can be a device of the same or a different type from theelectronic device 101. According to certain embodiments of thisdisclosure, the server 106 includes a group of one or more servers.Also, according to certain embodiments of this disclosure, all or someof the operations executed on the electronic device 101 can be executedon another or multiple other electronic devices (such as the electronicdevices 102 and 104 or server 106). Further, according to certainembodiments of this disclosure, when the electronic device 101 shouldperform some function or service automatically or at a request, theelectronic device 101, instead of executing the function or service onits own or additionally, can request another device (such as electronicdevices 102 and 104 or server 106) to perform at least some functionsassociated therewith. The other electronic device (such as electronicdevices 102 and 104 or server 106) is able to execute the requestedfunctions or additional functions and transfer a result of the executionto the electronic device 101. The electronic device 101 can provide arequested function or service by processing the received result as it isor additionally. To that end, a cloud computing, distributed computing,or client-server computing technique may be used, for example. WhileFIG. 1 shows that the electronic device 101 includes the communicationinterface 170 to communicate with the external electronic device 104 orserver 106 via the network 162 or 164, the electronic device 101 may beindependently operated without a separate communication functionaccording to some embodiments of this disclosure.

The server 106 can include the same or similar components 110-180 as theelectronic device 101 (or a suitable subset thereof). The server 106 cansupport to drive the electronic device 101 by performing at least one ofoperations (or functions) implemented on the electronic device 101. Forexample, the server 106 can include a processing module or processorthat may support the processor 120 implemented in the electronic device101.

Although FIG. 1 illustrates one example of a network configuration 100including an electronic device 101, various changes may be made toFIG. 1. For example, the network configuration 100 could include anynumber of each component in any suitable arrangement. In general,computing and communication systems come in a wide variety ofconfigurations, and FIG. 1 does not limit the scope of this disclosureto any particular configuration. Also, while FIG. 1 illustrates oneoperational environment in which various features disclosed in thispatent document can be used, these features could be used in any othersuitable system.

FIG. 2 illustrates an example process 200 for creating a Bokeh imageusing an electronic device in accordance with this disclosure. For easeof explanation, the process 200 shown in FIG. 2 is described as beingperformed using the electronic device 101 of FIG. 1. However, theprocess 200 shown in FIG. 2 could be used with any other suitableelectronic device and in any suitable system.

As shown in FIG. 2, the electronic device 101 includes two cameras orother imaging sensors. In this example, the imaging sensors include awide angle camera 205 and an ultra-wide angle camera 210. The cameras205 and 210 can be used to capture high-resolution images, and (as thenames imply) the images captured by the camera 210 can have a widerangle than the images captured by the camera 205. In some embodiments,the camera 205 can capture images having a resolution of 4,096 pixels by3,072 pixels, and the camera 210 can capture images having a resolutionof 4,608 pixels by 3,456 pixels. Note, however, that each camera 205 and210 may have another other suitable resolution, which may or may not bedifferent.

During operation, the cameras 205 and 210 can be used to capture imagesof the same scene at the same time while focused on the same object, butthe cameras 205 and 210 capture the images from slightly differentviews. The images are processed using a rectification function 215,which operates to crop and align the images. This produces alignedimages having the same field of view. The aligned images produced by therectification function 215 may have any suitable resolution. In someembodiments, the rectification function 215 produces images having aresolution of 2,048 pixels by 1,536 pixels, although other resolutionsmay be used. The rectification function 215 may use any suitabletechnique to rectify or align images. For example, the rectificationfunction 215 may use global Oriented FAST and Rotated BRIEF (ORB)features and local features from a block search to align the images.

A disparity detection function 220 processes the aligned images toproduce a disparity map 235. The disparity map 235 identifies pixeldifferences between the aligned images on a pixel-by-pixel basis and cantherefore have the same resolution as the aligned images. When multiplecameras 205 and 210 capture images at the same time, the pixeldifferences are (ideally) caused only by the different locations of thecameras 205 and 210 (which can be referred to as binocular disparity insome cases). In a disparity map 235, objects in the foreground of ascene have a larger disparity in images captured by the cameras 205 and210, and objects in the background of the scene have a smaller disparityin images captured by the cameras 205 and 210. Thus, disparity isinversely proportional to depth, and the disparity map 235 can alsofunction as a depth map for the scene being imaged. The disparitydetection function 220 may use any suitable technique to identifydisparity or depth in a scene using multiple images. In someembodiments, the disparity detection function 220 may be implementedusing a machine learning algorithm, such as one or more neural networklayers, that can be trained to recognize disparity or depth in images.

A computational Bokeh function 225 uses the disparity map 235 and atleast one of the images from the cameras 205, 210 to generate a finalBokeh image 230, which represents a captured image of the scene havingone or more blurred areas. The computational Bokeh function 225 canoperate as described below in order to provide the Bokeh effect based ona range of depths of focus, which can be defined by a user. For example,the computational Bokeh function 225 can take the image captured by thecamera 205, ensure that image data with the defined depth of focus rangeis sharp, and blur image data outside the defined depth of focus range.The Bokeh image 230 here can have the same resolution as the imagecaptured by the camera 205, such as 4,096 pixels by 3,072 pixels(although other resolutions may be used).

Each function 215, 220, 225 shown in FIG. 2 can be implemented in anysuitable manner For example, in some embodiments, one or more functions215, 220, 225 can be implemented or supported using one or more softwareapplications or other software instructions that are executed by theprocessor 120 of the electronic device 101. In other embodiments, one ormore functions 215, 220, 225 can be implemented or supported usingdedicated hardware components. In general, the operations of anelectronic device can be performed using any suitable hardware or anysuitable combination of hardware and software/firmware instructions.

Although FIG. 2 illustrates one example of a process 200 for creating aBokeh image using an electronic device, various changes may be made toFIG. 2. For example, the electronic device may perform any other desiredfunctions as part of the process 200 or as part of a larger imageprocessing algorithm. As particular example, the images from the cameras205, 210 may undergo other suitable pre-processing operations, and theBokeh image 225 may undergo any suitable post-processing operations.

FIG. 3 illustrates an example process 300 for applying computationalBokeh to an image in accordance with this disclosure. The process 300shown in FIG. 3 may, for example, represent one possible implementationof the computational Bokeh function 225 used in the process 200 of FIG.2. For ease of explanation, the process 300 shown in FIG. 3 is describedas being performed using the electronic device 101 of FIG. 1. However,the process 300 shown in FIG. 3 could be used with any other suitableelectronic device and in any suitable system.

As shown in FIG. 3, the process 300 receives various inputs, such as animage from the camera 205, a disparity map 235 from the disparitydetection function 220, and one or more screen touch points (which aredescribed below and can be used to define a depth of focus range). Theprocess 300 performs various functions to produce a final Bokeh image230. A focus range determination step 310 receives the various inputshere and allows a user to manipulate a depth of focus range throughinteractions with a touchscreen of the electronic device 101. Exampleoperations of the focus range determination step 310 are described belowwith reference to FIGS. 4 and 5.

A circle of confusion (CoC) curve determination step 320 converts thedepth of focus range provided by the focus range determination step 310into a disparity focus range and generates a CoC curve. As describedbelow, a CoC curve can be used to define the amount of blur to beapplied to the image from the camera 205. Example operations of the CoCcurve determination step 320 are described below with reference to FIGS.6, 7, 8A through 8D, and 9A and 9B.

A layer determination step 330 uses the CoC curve to define multiplelayers associated with the image from the camera 205, where each layerrepresents a range of disparity in a scene or image. This can be done byusing the CoC curve and comparing the disparity in the image from thecamera 205 to maximum and minimum disparities associated with the depthof focus range. Example operations of the layer determination step 330are described below with reference to FIGS. 10 and 11.

A scatter at various layers step 340 processes the identified layers toproduce the Bokeh effect in the image from the camera 205. For example,the scatter at various layers step 340 can apply kernels of differentsizes to each layer in order to blur the image data in different ways.The scatter at various layers step 340 can also generate alpha blendingmaps to be used to combine the layers. Example operations of the scatterat various layers step 340 are described below with reference to FIGS.10 and 12.

A blend various layers step 350 blends the various layers provided bythe scatter at various layers step 340 based on the blending mapsprovided by the scatter at various layers step 340. For example, theblend various layers step 350 can blend the layers in order ofdecreasing distance from the camera 205, accumulating image data layerby layer to produce the final Bokeh image 230. Example operations of theblend various layers step 350 are described below with reference toFIGS. 13 and 14.

Each step 310, 320, 330, 340, 350 shown in FIG. 3 can be implemented inany suitable manner For example, in some embodiments, one or more steps310, 320, 330, 340, 350 can be implemented or supported using one ormore software applications or other software instructions that areexecuted by the processor 120 of the electronic device 101. In otherembodiments, one or more steps 310, 320, 330, 340, 350 can beimplemented or supported using dedicated hardware components. Ingeneral, the operations of an electronic device can be performed usingany suitable hardware or any suitable combination of hardware andsoftware/firmware instructions.

Although FIG. 3 illustrates one example of a process 300 for applyingcomputational Bokeh to an image, various changes may be made to FIG. 3.For example, the electronic device may perform any other desiredfunctions as part of the process 300 or as part of a larger imageprocessing algorithm.

FIG. 4 illustrates an example user interface 400 for receiving touchinputs that define a depth of focus range in accordance with thisdisclosure. The user interface 400 may, for example, be used to obtain adepth of focus range from a user, and the depth of focus range can beprovided as an input to the focus range determination step 310. For easeof explanation, the user interface 400 shown in FIG. 4 is illustrated asbeing provided by a specific type of electronic device 101 (namely asmartphone) in FIG. 1. However, the user interface 400 shown in FIG. 4could be used with any other suitable electronic device and in anysuitable system.

As shown in FIG. 4, the user interface 400 is displayed on a touchscreenof the electronic device 101 and includes a preview screen 410 andvarious controls 415, 420, 425. The preview screen 410 can display oneor more preview images of a scene as captured by at least one camera205, 210 of the electronic device 101. In some cases, a user can touch aspecific point 405 on the preview screen 410 associated with an objector area the user would like to keep in focus. The preview screen 410 canalso display the preview image with an estimated Bokeh effect based onthe user's touchpoint, an object class, associated with the object inthe image, and the controls 415, 420.

The controls 415, 420 allow a user to manipulate the depth of focusrange in the preview image. For example, the control 415 can represent aslide bar or other input mechanism that allows the user to adjust themaximum depth of focus 430, such as by moving the bar left or right.Similarly, the control 420 can represent a slide bar or other inputmechanism that allows the user to adjust the minimum depth of focus 435,such as by moving the bar left or right. As noted above and as describedin more detail below, image data within the depth of focus range (asdefined by the maximum depth of focus 430 and the minimum depth of focus435) can be sharp in the Bokeh image 230, while image data outside thedepth of focus range can be blurred to provide the Bokeh effect. In thisway, the user can interactively define and control what areas of theimage remain in focus and what areas become blurry. Other controlbuttons, such as an “OK” button 425, allow the user to accept the imageas adjusted.

Although FIG. 4 illustrates one example of a user interface 400 forreceiving touch inputs that define a depth of focus range, variouschanges can be made to FIG. 4. For example, the various controls can beimplemented in any other suitable manner that allows a user to define adepth of focus range.

FIG. 5 illustrates an example method 500 of determining an adaptivefocus range in accordance with this disclosure. The method 500 may, forexample, be performed as part of the focus range determination step 310based on input received via the user interface 400. For ease ofexplanation, the method 500 shown in FIG. 5 is described as beingperformed by the electronic device 101 of FIG. 1. However, the method500 shown in FIG. 5 could be performed by any other suitable electronicdevice with any other suitable user interface and in any suitablesystem.

As shown in FIG. 5, in step 510, the user interface 400 receives a touchpoint 405 on the preview screen 410 defining a focus position in ascene. This allows a focus position D within the scene to be identified,and the depth of focus at that focus position can be identified. Thedepth of focus at the focus position can be determined in any suitablemanner, such as based on the disparity identified at the focus position.

In step 520, an object class is identified based on the object that liesat the focus position D. Different object classes define average depthsfor different objects, and the electronic device 101 may identify theobject that lies at the focus position D (such as by using patternrecognition) and then identify the object class for that object. Forexample, the object that lies at the focus position D may represent aperson, and a person object class may define the average thickness of ahuman to be about 0.55 meters (about 1.8 feet). Various object classescan be defined based on a number of different objects, such as people,cars, trees, animals, food, and other objects.

In step 530, an initial depth of focus range in a scene is determinedbased on the focus position D and the thickness associated with theidentified object class. For example, the electronic device 101 may setthe minimum depth of focus 435 to be the focus position D minus a frontthickness value T1, and the electronic device 101 may set the maximumdepth of focus 430 to be the focus position D plus a back thicknessvalue T2. This can be expressed as:

depth_(min) =D−T1  (1)

depth_(max) =D+T2  (2)

Here, the values of T1 and T2 may be selected so that the averagethickness of the object in the scene at the focus position D is includedin the initial range of focus. Note that if the object in the scene atthe focus position D has no associated object class, the values of T1and T2 may be set to default values. Essentially, this allows theelectronic device 101 to estimate, based on the focus position D and theaverage depth of the object, what the initial depth of focus rangeshould be.

In step 540, a Bokeh preview is generated and presented via the userinterface 400. For example, the electronic device 101 may generate animage of the scene, where the image includes the Bokeh effect asgenerated using the initial depth of focus range. In step 550, adetermination is made whether the user accepts the preview or would liketo further adjust the depth of focus range. If the user accepts thepreview, the user can hit the OK button 425 in step 560, and the depthof focus range is stored for use in generating a final Bokeh image 230.If the user does not accept the preview, the user manipulates one orboth controls 415, 420 to the user's preference in step 570, and theprocess returns to step 540 to update the Bokeh preview based on themodified settings.

The ability of a user to adaptively define a depth of focus rangeenables (among other things) an image to include the Bokeh effect in thebackground only or in both the background and the foreground of a scene(such as when the field of depth is large). In a conventional camera,when trying to capture an image of two people at different depths in ascene, the focus can be set on the front person, and the back personwill be blurred. In order to capture both people in focus, the aperturewould be reduced to increase the field of depth, resulting in thebackground not being very blurry and the foreground of the imageremaining sharp. In accordance with this disclosure, the minimum andmaximum depths of focus can be controlled independently, which allowsthe user to adjust both the background blur level and the foregroundblur level. The resulting large depth of field is physically impossiblefor conventional DSLR cameras to produce.

Although FIG. 5 illustrates one example of a method 500 of determiningan adaptive focus range, various changes can be made to FIG. 5. Forexample, while shown as a series of steps, various steps in FIG. 5 couldoverlap, occur in parallel, occur in a different order, or occur anynumber of times.

FIG. 6 illustrates an example method 600 of determining a CoC curve inaccordance with this disclosure. The method 600 may, for example, beperformed as part of the CoC curve determination step 320. For ease ofexplanation, the method 600 shown in FIG. 6 is described as beingperformed by the electronic device 101 of FIG. 1. However, the method600 shown in FIG. 6 could be performed by any other suitable electronicdevice with any other suitable user interface and in any suitablesystem.

As shown in FIG. 6, in step 610, the electronic device 101 receives anadaptive depth of focus range in a scene, which may be generated usingthe method 500 of FIG. 5. In step 620, the adaptive focus range isconverted from a depth focus range to a disparity focus range. This canbe done in any suitable manner since disparity is inversely proportionalto depth. One example technique for converting a depth focus range to adisparity focus range is described below with respect to FIG. 7. Asdescribed below, the disparity focus range is associated with a maximumdisparity d_(max) (associated with the minimum depth of focus 435) and aminimum disparity d_(min) (associated with the maximum depth of focus430).

In step 630, the disparity focus range is refined through amulti-resolution search in a disparity histogram. That is, the exactvalues for the maximum disparity d_(max) and the minimum disparityd_(min) can be altered using the disparity histogram. One example ofthis is described below with respect to FIGS. 8A, 8B, 8C, and 8D.

In step 640, a CoC curve of a current scene is determined using therefined disparity focus range. The CoC curve here is used to satisfy theuser's depth of focus range and create a virtual camera whose parametersettings are physically impossible to replicate using real-world optics.One example of this is described below with respect to FIGS. 9A and 9B.

Although FIG. 6 illustrates one example of a method 600 of determining aCoC curve, various changes can be made to FIG. 6. For example, whileshown as a series of steps, various steps in FIG. 6 could overlap, occurin parallel, occur in a different order, or occur any number of times.

FIG. 7 illustrates an example conversion from depth space to disparityspace in accordance with this disclosure. This technique may, forexample, be used as part of step 620 in the method 600 of FIG. 6. Asnoted above, in order to produce a Bokeh image based on an adaptivedepth of focus range, the depth of focus range is converted from a depthspace into a disparity space. Disparity is inversely proportional todepth, so maximum depth becomes minimum disparity and vice versa.

As shown in FIG. 7, a point 705 (labeled X) represents a point on atarget object to be captured by a left camera 710 (labeled O) and aright camera 715 (labeled O′). These cameras 710, 715 may represent thetwo cameras 205, 210 described above. Because the cameras 710, 715 donot capture images from the exact same direction, a disparity exists inthe location of the point 705 in images captured by the camera 710 andthe location of the point 705 in images captured by the camera 715(assuming both cameras 710, 715 are pointing directly upward here).Thus, the point 705 is offset from a visual axis of the camera 710 at aposition 720 (labeled x) and is offset from a visual axis of the camera715 at a position 725 (labeled x′). In this example, the focal lengths730 (labeled F) of the cameras 710, 715 are assumed to be equal, and abaseline 740 (labeled B) represents the distance between the cameras710, 715.

Based on this, a depth 750 from the cameras 710, 715 to the point 705can be calculated using the baseline 740 and the distances of x and x′in FIG. 7. More specifically, the depth 750 can be calculated asBF/(x−x′). The expression (x−x′) here represents the disparity in theimage for the point 705, so the disparity associated with the point 705can be expressed as BF/d, where d represents the depth 750.

As can be seen here, the maximum and minimum depths of focus 430, 435are positioned behind and in front of the point 705. This helps toensure that the object associated with the point 705 is in focus in afinal Bokeh image 230. This also means that a range of disparity valuescan be determined based on the maximum and minimum depths of focus 430,435. For example, the maximum disparity d_(max) may be calculated asd_(max)=BF/depth_(min), and a minimum disparity d_(min) may becalculated as d_(min)=BF/depth_(max). The maximum and minimum disparityvalues calculated in this manner may represent the initial disparityvalues calculated in step 620, and these disparity values can be refinedduring step 630 as described below.

Although FIG. 7 illustrates one example of a conversion from depth spaceto disparity space, various changes may be made to FIG. 7. For example,FIG. 7 is not necessarily drawn to scale and is merely meant toillustrate one example of how depth information can be converted intodisparity information.

FIGS. 8A, 8B, 8C, and 8D illustrate an example multi-resolutiondisparity focus range refinement using a disparity histogram inaccordance with this disclosure. As noted above, the initial maximumdisparity d_(max) and minimum disparity d_(min) may be refined using amulti-resolution search in a disparity histogram. This may be necessaryor desirable since the original maximum and minimum disparity values areestimated based on the depth to a single point (point 705 in FIG. 7)even though they are associated with different focus depths.

As shown in FIG. 8A, a disparity histogram 805 has been produced usingthe disparity values previously calculated by the electronic device 101.In the disparity histogram 805, the disparity values are placed in 32bins, which (assuming the disparity values may range from 0-255)represent ⅛ of the original resolution of the disparity values. Startingat an initial position 810 on one side of the central bin, a search tothe left of the histogram 805 is made to identify a local minimum orvalley in the histogram 805, which in this example occurs in bin 815.The initial position 810 here represents the bin that includes theinitial minimum disparity d_(min). Similarly, starting at an initialposition 820 on the other side of the central bin, a search to the rightof the histogram 805 is made to identify a local minimum or valley inthe histogram 805, which in this example occurs in bin 825. The initialposition 820 here represents the bin that includes the initial maximumdisparity d_(max).

As shown in FIG. 8B, a disparity histogram 830 has been produced usingthe same disparity values previously calculated by the electronic device101. In the disparity histogram 830, the disparity values are placed in64 bins, which (assuming the disparity values may range from 0-255)represent ¼ of the original resolution of the disparity values. A searchto the left of the histogram 830 is made starting at the bin 815identified earlier to identify a local minimum or valley in thehistogram 830 (bin 835), and a search to the right of the histogram 830is made starting at the bin 825 identified earlier to identify a localminimum or valley in the histogram 830 (bin 840).

As shown in FIG. 8C, a disparity histogram 845 has been produced usingthe same disparity values previously calculated by the electronic device101. In the disparity histogram 845, the disparity values are placed in128 bins, which (assuming the disparity values may range from 0-255)represent ½ of the original resolution of the disparity values. A searchto the left of the histogram 845 is made starting at the bin 835identified earlier to identify a local minimum or valley in thehistogram 845 (bin 850), and a search to the right of the histogram 845is made starting at the bin 840 identified earlier to identify a localminimum or valley in the histogram 845 (bin 855).

As shown in FIG. 8D, a disparity histogram 860 has been produced usingthe same disparity values previously calculated by the electronic device101. In the disparity histogram 860, the disparity values are placed in256 bins, which (assuming the disparity values may range from 0-255)represent the original resolution of the disparity values. A search tothe left of the histogram 860 is made starting at the bin 850 identifiedearlier to identify a local minimum or valley in the histogram 860 (bin865), and a search to the right of the histogram 860 is made starting atthe bin 855 identified earlier to identify a local minimum or valley inthe histogram 860 (bin 870). The two bins identified here (bins 865 and870 in this example) represent the new values for the minimum disparityd_(min) and the maximum disparity d_(max).

Although FIGS. 8A, 8B, 8C, and 8D illustrate one example of amulti-resolution disparity focus range refinement using a disparityhistogram, various changes may be made to these figures. For example,the specific histograms and the specific bins identified during thesearches are for illustration only and can vary based on the image databeing processed. Also, note that in each histogram it is assumed thereis a valley identified during a left or right search, although that maynot necessarily occur (in which case the current bin from which the leftor right search started can be used as the starting position in the nexthistogram, if any).

FIGS. 9A and 9B illustrate an example comparison of CoC curves definedover a depth or disparity range in accordance with this disclosure. Inparticular, FIG. 9A illustrates a CoC curve associated with aconventional camera, such as a DSLR camera, and FIG. 9B illustrates aCoC curve that may be generated according to the teachings of thisdisclosure.

A circle of confusion refers to the shape that light from a point formson an imaging plane. When the light is in focus on the imaging plane,the light from the point also appears as a point on the imaging plane.When the light is out-of-focus on the imaging plane, the light from thepoint appears as a circle on the imaging plane (assuming the imagingplane is perpendicular to the light path), and the size of the circledepends on how out-of-focus the light is. As a result, a larger circleof confusion results in more blur, and a smaller circle of confusionresults in less blur. This effect can be used in the imagingfunctionality described in this disclosure by defining different circlesof confusion to different pixels in an image from the camera 205,thereby providing different amounts of blur to those pixels andachieving a desired Bokeh effect.

As shown in FIG. 9A, a CoC curve 905 for a standard DSLR camera isdefined over depth. As can be seen here, the CoC curve 905 isnon-linear, and there is a single focus position 910. As depth increasesbeyond the focus position 910, the CoC curve 905 rises quickly butbegins to flatten out. As depth decreases in front of the focus position910, the CoC curve 905 rises sharply (almost as a vertical line in thisexample). This indicates that in a typical DSLR camera, the focus rangeis not controllable and, as a result, the foreground increases inblurriness very quickly while the background increases in blurrinessmore gradually.

As shown in FIG. 9B, a CoC curve 915 can be defined over disparity bythe CoC curve determination step 320. In this example, a refined minimumdisparity 920 and a refined maximum disparity 925 can represent thevalues identified using the histogram-based approach described above. Ascan be seen here, the CoC curve 915 includes a piecewise linear curvehaving three linear segments, one decreasing towards the refined minimumdisparity 920, one steady at zero between the refined disparities 920and 925, and one increasing from the refined maximum disparity 925. Therefined minimum disparity 920 and refined maximum disparity 925 heredefine a range of focus positions at which an image may remain in focussince the circle of confusion is zero, which is not something achievableusing conventional optics. Based on this, it is possible for theelectronic device 101 to apply different circles of confusion todifferent pixels in an image to blur those pixels, while other pixels ina desired depth of focus range can remain sharp. Also, the CoC curve 915results in an image in which both the foreground and background canlinearly increase in blurriness moving away from the range of focus.

In some embodiments, the CoC curve 915 used for a particular image canbe determined as follows. When a CoC curve 915 is applied to an image,the CoC is applied based on a disparity map (instead of a depth map) inorder to achieve an adaptive depth of focus range. Given that, when theCoC curve ≤1 (that is, the circle of confusion is less than one pixel),the corresponding pixel is sharp. Otherwise, when the CoC curve >1 (thatis, the circle of confusion is larger than one pixel), the correspondingpixel is blurred by some amount as defined by the CoC curve. The CoCcurve for a particular image can be calculated using the followingequation:

$\begin{matrix}{{CoC} = {\frac{fs}{\rho N}{{\frac{1}{f} - \frac{Disparity}{BF} - \frac{1}{s}}}}} & (3)\end{matrix}$

where CoC represents a diameter of the circle of confusion in pixels, frepresents a focal length of the virtual camera, s represents a distancebetween the camera lens and an imaging plane, N represents the f-stopnumber of the aperture (meaning N=f/aperture diameter), r represents thepixel size, F represents the focal length of the wide camera 205, and Brepresents the baseline distance between the cameras 205, 210. InEquation (3), the values of s, r, F, and B are constants and aretypically determined during factory calibration. Also, f and N arecalculated here such that all pixels whose disparities are within therange defined by the refined disparity values 920, 925 are sharp,meaning CoC ≤1 for those pixels. By doing so, this simulates the processphotographers take when they manually adjust the focal length andaperture settings on a DSLR camera while maintaining the focus point.

In some embodiments, Equations (4) and (5) below are used to solve for fand N:

$\begin{matrix}{{\frac{fs}{\rho N}( {\frac{1}{f} - \frac{d_{m\; i\; n}}{BF} - \frac{1}{s}} )} = 1} & (4) \\{{\frac{fs}{\rho N}( {\frac{1}{f} - \frac{d_{{ma}\; x}}{BF} - \frac{1}{s}} )} = {- 1}} & (5)\end{matrix}$

Once f and N are solved, the CoC curve can be calculated using Equation(3). By following this process, a virtual camera is created in whichparameter settings are physically impossible to replicate withreal-world optics, but the parameter settings do satisfy a user's depthof focus range to create an adaptive Bokeh effect. Note that in otherembodiments, the CoC curve used for a specific image can be furtherprocessed, such as by sampling values defined by the CoC curve into anarray and applying a low-pass filter. Graphically speaking, this may beequivalent to rounding the edges of the CoC curve 915 in FIG. 9B aroundthe disparity values 920, 925.

Although FIGS. 9A and 9B illustrate one example of a comparison of CoCcurves defined over a depth or disparity range, various changes may bemade to FIGS. 9A and 9B. For example, the curves, focus positions, andranges shown in FIGS. 9A and 9B are for illustration only and are merelymeant to illustrate examples of specific CoC curves. The CoC curveapplied to any specific image may vary from what is shown here. Also, itis not necessarily required that a CoC curve 915 be formed using linearsegments.

FIG. 10 illustrates an example method 1000 of layer determination andlayered scattering in accordance with this disclosure. The method 1000may, for example, be performed as part of the layer determination step330 and the scatter at various layers step 340. For ease of explanation,the method 1000 shown in FIG. 10 is described as being performed by theelectronic device 101 of FIG. 1. However, the method 1000 shown in FIG.10 could be performed by any other suitable electronic device with anyother suitable user interface and in any suitable system.

As shown in FIG. 10, in step 1005, multiple layers associated with animage being processed are determined based on a CoC curve 915. Forexample, different layers may be associated with different segments ofthe CoC curve 915. One example technique for defining layers is providedbelow with reference to FIG. 11. In step 1010, a high resolution inputimage is down-sampled into an accumulation buffer. This may includedown-sampling the image from the camera 205 to produce alower-resolution image. Here, layered scattering may be performed at alower resolution than the input image to provide computational savings,although that is not necessarily required. For example, assume theelectronic device 101 captures a wide high-resolution image S_(H). Theelectronic device 101 may down-sample the high-resolution image S_(H) toa lower-resolution image S_(L). An accumulation buffer (denoted A) canthen be used to store the lower-resolution image S_(L).

In step 1015, the farthest layer (denoted N) in terms of distance fromthe virtual camera is selected, and the farthest layer should correspondto the furthest background in a scene. The other layers may be numberedin decreasing numerical order as the distance from the virtual cameradecreases. Thus, in this example, the layers are processed in order fromfarthest to nearest. Each layer here represents a different range ofdisparities and therefore different segments of the CoC curve 915.

In step 1020, scattering is performed at the current layer using aspecific kernel for that layer. The kernel applied to each specificlayer is based on the portion of the CoC curve 915 associated with thatlayer. An example of this is described below with reference to FIG. 12.The application of the kernel to the current layer may result inblurring of the image data associated with that layer (unless the kernelused for the current layer is associated with disparities between therefined disparity values 920, 925). In either case, the output of thisstep is an image layer I(p).

In step 1025, an alpha blending map α(p) is calculated for the currentlayer. In step 1030, the image layer I(p) is blended with a prior layerbased on the alpha blending map α(p) into the accumulation buffer A. Theprior layer here represents the current contents of the accumulationbuffer A, and the results from the blending are stored into theaccumulation buffer A (overwriting the prior contents). Alpha blendingrefers to a type of blending where a value a is defined for each pixellocation, where the pixel value in one image is weighted by α, the pixelvalue in another image is weighted by (1−α), and the weighted pixelvalues are summed to compute a new pixel value in a new image. Note thatfor the first layer being processed, this step may be skipped, thecontents of the first layer may be stored in the accumulation buffer A.

In step 1030, the current contents of the accumulation buffer and thecurrent alpha blending map are output if the current layer is one of thelast two layers being processed. This supports the processing of imagedata as discussed below. In step 1040, a determination is made whetherthe current layer represents the last layer to be processed. If not, thenext-closest layer is selected, and the process returns to step 1020 toperform scatting using a different kernel. Essentially, as the processproceeds here, the accumulation buffer is updated during each iterationto store a blended version of all prior layers, moving farthest toclosest.

If the current layer represents the last layer to be processed, two setsof image data (the contents of the accumulation buffer for both the lastlayer and the second-to-last layer) and two alpha blending maps havebeen generated and output. In step 1245, this data is upsampled. Here,Layer0 represents the image data from the accumulation buffer for thelast layer processed, Alpha0 represents the alpha blending map for thelast layer processed, Layer1 represents the image data from theaccumulation buffer for the second-to-last layer processed, and Alpha1represents the alpha blending map for the second-to-last layerprocessed. This data can be upsampled in order to support to generationof a high-resolution final Bokeh image 230, which is produced in step1050. This is explained further below with reference to FIGS. 13 and 14.

Although FIG. 10 illustrates one example of a method 1000 of layerdetermination and layered scattering, various changes may be made toFIG. 10. For example, while shown as a series of steps, various steps inFIG. 10 could overlap, occur in parallel, occur in a different order, oroccur any number of times.

FIG. 11 illustrates an example definition of multiple layers based on aCoC curve 915 defined over disparity in accordance with this disclosure.The multiple layers here may, for example, be identified by the layerdetermination step 330 and used by the scatter at various layers step340.

As noted above, the CoC curve 915 is defined over disparity values, anddifferent ranges of disparity values can be associated with differentlayers processed by the electronic device. The different layers allowvarying degrees of blurriness to be applied to an image via layeredscattering as described above. In this particular example, there arefour layers 1100, 1110, 1120, and 1130 defined. In particular, layer1100 represents the foreground of a scene and is associated withdisparities greater than the refined disparity 925, and layer 1110represents the desired depth of focus range of the scene and isassociated with disparities between the refined disparities 920, 925.Also, disparities less than the refined disparity 920 are associatedwith two layers 1120 and 1130, which respectively represent the nearbackground and the far background in the scene.

In the method 1000 described above, a final Bokeh image 230 of a scenecan be produced by taking image data associated with the layer 1130 andalpha-blending that image data with the image data associated with thelayer 1120. The resulting image data is stored in the accumulationbuffer and is alpha-blended with the image data associated with thelayer 1110. The resulting image data is stored in the accumulationbuffer, and the resulting image data and associated alpha blending mapare output as Layer1 and Alpha1 in the method 1000. The resulting imagedata is also alpha-blended with the image data associated with the layer1100, and the resulting image data and the associated alpha blending mapare output as Layer0 and Alpha0 in the method 1000. Thus, as describedabove, the layers are processed in order to distance from farthest toclosest, with image data being blended as the layers are processed inthat order.

Although FIG. 11 illustrates one example of a definition of multiplelayers based on a CoC curve, various changes can be made to FIG. 11. Forexample, a CoC curve may be divided into less or more than four layers.For instance, the background may be divided into any number of layers,and the foreground may be divided into any number of layers.

FIG. 12 illustrates an example kernel 1200 in accordance with thisdisclosure. The kernel 1200 here may, for example, be used by thescatter at various layers step 340 to apply blurriness to image databeing processed. The kernel 1200 here applies weights to differentpixels within a circle of confusion around a central pixel at position(0, 0), where the weights can vary based on the positions of the pixelsaround the central pixel. Essentially, this can be viewed as each pixelsending out its intensity to its neighboring pixels following the kernelcoefficients (weights), so each pixel receives multiple intensitiescoming from multiple sources (adjacent pixels). The final intensity of aparticular pixel is defined as the weighted average of all incomingintensities. The kernel 1200 here therefore represents the weightassociated with a pixel at a neighboring position (i, j) as W_(i,j), andthe weights associated with all pixels within the circle of confusionmay or may not be the same.

In some embodiments, the size of the kernel 1200 is proportional to theCoC value as defined by the CoC curve 915. Thus, larger values in theCoC curve 915 are associated with larger kernels 1200, and smallervalues in the CoC curve 915 are associated with smaller kernels 1200. Inparticular embodiments, a uniform kernel 1200 (a kernel having uniformweights) may be applied to the farthest layer (layer 1130 in FIG. 11),and a rational kernel 1200 may be applied for all other layers. Arational kernel 1200 for a particular layer may include weightscalculated using the following equations:

$\begin{matrix}{{{func}( {r,x} )} = \frac{( {{2x} + r} )( {x - r} )^{2}}{r^{3}}} & (6) \\{w_{i,j} = {\min ( {0.618,{{func}( {\frac{CoC}{\sqrt{2}},{{i} + {j}}} )}} )}} & (7)\end{matrix}$

where all coefficients are normalized to sum to a value of one. Giventhese definitions, the following formula may be used to produce theimage data as a result of a particular scattering (as performed in step1020 described above):

$\begin{matrix}{{{destination}\mspace{14mu} {pixel}} = {\frac{\Sigma \; {source}\mspace{14mu} {pixel}_{({i,j})}*{kernel}\mspace{14mu} {weight}_{({i,j})}}{\Sigma \; {kernel}\mspace{14mu} {weight}_{({i,j})}}.}} & (8)\end{matrix}$

To produce a final Bokeh image 230, the various layers are blendedtogether in a back-to-front fashion as noted above and as explained inmore detail below with reference to FIGS. 13 and 14. Also as describedbelow, the alpha blending maps are created during the layer scatteringoperation to produce a final Bokeh image 230 that reduces or eliminatesartifacts such as the halo effect. In some embodiments, each alphablending map is produced for a specific layer using the followingequation:

alpha at destination pixel=Σkernel weight_((i,j)).

Although FIG. 12 illustrates one example of a kernel 1200, variouschanges may be made to FIG. 12. For example, as noted above, the size ofthe kernel 1200 can vary based on the associated disparity as defined bythe CoC curve 915.

FIGS. 13 and 14 illustrate an example process 1300 for final compositionof a Bokeh image in accordance with this disclosure. The process 1300may, for example, be performed as part of the blend various layers step350. For ease of explanation, the process 1300 shown in FIG. 13 isdescribed as being performed by the electronic device 101 of FIG. 1.However, the process 1300 shown in FIG. 13 could be performed by anyother suitable electronic device with any other suitable user interfaceand in any suitable system.

As shown in FIG. 13, the layered blending of image data here starts witha scattering background 1305, which represents the farthest layer (suchas layer 1130) or a bended version of the farthest layers (such aslayers 1120 and 1130). Thus, the scattering background 1305 mayrepresent the accumulation of all previous layers of image data. Analpha map 1310 (Alpha1) associated with an image layer 1315 (Layer1) isgenerated and used to blend the scattering background 1305 with theimage layer 1315 to produce blended image data. An alpha map 1320(Alpha0) associated with a scattering foreground 1325 (Layer0) isgenerated and used to blend the blended image data from the prior layerswith the image data in the scattering foreground 1325.

Note that the image layer 1315 here can represent a high-resolutionimage, such as the image from the camera 205. This allows the scatteringbackground 1305 to be used to produce the Bokeh effect in the backgroundof the image from the camera 205 and the scattering foreground 1325 tobe used to produce the Bokeh effect in the foreground of the image fromthe camera 205. In this way, the scattering concept is applied in anordered, layered fashion from back-to-front so that the foreground layeroverwrites the background layer when necessary. In addition, byalpha-blending the layers, halo artifacts present in many computationalBokeh images is reduced or eliminated.

FIG. 14 illustrates how the processing described above can be used toproduce image data that can then be processed as shown in FIG. 13 toproduce a final Bokeh image 230. In this example, image data isprocessed after down-sampling as described above, and the image data isprocessed in order of decreasing distance in a scene. Here, image data1405 (representing the farthest layer) is blended with image data 1410(representing the next farthest layer) based on an alpha blending map1415 to produce image data 1420. The image data 1420 is blended withimage data 1425 based on an alpha blending map 1430 to produce imagedata 1435. The image data 1435 is blended with image data 1440 based onan alpha blending map 1445 to produce image data 1450. Various resultsproduced here are then upsampled into the high-resolution domain. Thisproduces the various layers 1305, 1315, 1325 and blending maps 1310,1320, which can be used as described above to produce the final Bokehimage 230.

In other embodiments, single-resolution scattering can be performed.That is, all layers can be rendered at the highest resolution, insteadof performing steps to down-sample the layers, perform scattering, andup-sample the output layers. In still other embodiments, pyramidscattering can be performed. That is, instead of down-sampling the highresolution image S_(H) uniformly across all layers, each layer can bescaled down individually. For instance, the far-background layer may bedown-sampled to a 1/16 resolution of the input image, and the otherlayers may be down-sampled to a ¼ resolution of the input image. Notethat other scattering operations may occur here without departing fromthe scope of this disclosure.

Although FIGS. 13 and 14 illustrate one example of a process for finalcomposition of a Bokeh image, various changes may be made to FIGS. 13and 14. For example, while certain numbers of layers may be used here,other numbers of layers may also be used.

FIGS. 15A and 15B illustrate example alpha blending maps in accordancewith this disclosure. For example, FIG. 15A illustrates an alphablending map 1510 that may correspond to map 1320 in FIGS. 13 and 14,and FIG. 15B illustrates an alpha blending map 1520 that may correspondto map 1310 in FIGS. 13 and 14. In these examples, white values mayindicate that pixels from one image are to be weighted to the maximumextent, and black values may indicate that pixels from one image are tobe weighted to the minimum extent (although the opposite could also betrue). Grayscale values may indicate fractional combinations of pixels.

In the process described above, the alpha blending map 1510 causes theimage data from the high-resolution image S_(H) to remain for the targetof the image (a person in this example), which keeps the final imagesharp in those areas. However, the background data produced using thefarther layers remains, allowing the blurriness introduced in earlierblending operations to remain. Similarly, the alpha blending map 1520allows foreground image data to be blurred and to overwrite prior imagedata produced in the earlier blending operations, but it does notoverwrite the image data from the high-resolution image S_(H) for thetarget or the background.

Although FIGS. 15A and 15B illustrate examples of alpha blending maps,various changes may be made to FIGS. 15A and 15B. For example, the alphablending maps shown here are examples only and are based on specificimage data being captured. Other alpha blending maps would be generatedfor other image data.

FIG. 16 illustrates an example combination of image layers to create afinal Bokeh image in accordance with this disclosure. As shown in FIG.16, a foreground layer 1610 represents a combination of foreground imagedata produced by the scattering performed on the nearest layer(s) asdescribed above and the alpha blending map 1520. A focus layer 1620represents a combination of the high-resolution image S_(H) and thealpha blending map 1510. A background layer 1630 represents acombination of the background image data produced by the scatteringperformed on the farthest layer(s) as described above and the areas notidentified in white in the alpha blending maps 1510, 1520. These layers1610, 1620, 1630 can be combined to produce a final Bokeh image 1640.

Although FIG. 16 illustrates one example of a combination of imagelayers to create a final Bokeh image, various changes can be made toFIG. 16. For example, while three layers of image data are shown here,other numbers of image data layers may also be used.

FIGS. 17A and 17B illustrate an example comparison of images inaccordance with this disclosure. In particular, FIG. 17A illustrates aBokeh image 1710 generated using a DSLR camera, and FIG. 17B illustratesa Bokeh image 1720 generated using the approaches described in thispatent document.

As can be seen in FIG. 17A, a person is reaching his arm backwards,which causes his hand to be farther away depth-wise from a cameracapturing the image 1710. As a result, while the person's face isgenerally in focus, the person's hand is not. This is because the opticsof a DSLR camera cannot provide a depth of focus range. As can be seenin FIG. 17B, the image 1720 can be generated after a user defines adepth of focus range that includes the person's face and hand. Using thetechniques described above, both the person's face and the person's handare in focus in the image 1720, while the background remains blurry andprovides the Bokeh effect.

Although FIGS. 17A and 17B illustrate one example of a comparison ofimages, various changes may be made to FIGS. 17A and 17B. For example,these images are merely meant to illustrate the type of effect that maybe achieved using the techniques described above. Of course, otherscenes and other implementations of the techniques described above mayproduce different results than those shown here.

Although this disclosure has been described with reference to variousexample embodiments, various changes and modifications may be suggestedto one skilled in the art. It is intended that this disclosure encompasssuch changes and modifications as fall within the scope of the appendedclaims.

1. A method comprising: determining, using at least one processor, adepth of focus range for a scene; determining, using the at least oneprocessor, multiple layers associated with the scene based on the depthof focus range, each layer associated with image data having a differentrange of disparity values, wherein determining the multiple layerscomprises (i) converting maximum and minimum depths of focus intomaximum and minimum disparities, (ii) generating a circle of confusion(CoC) curve based on the maximum and minimum disparities, and (iii)identifying the multiple layers based on different portions of the CoCcurve; and blending, using the at least one processor, the multiplelayers to produce an image having (i) a Bokeh effect in a foreground anda background and (ii) focused image data within the depth of focusrange, wherein the multiple layers include at least a first layerassociated with the foreground, a second layer associated with the depthof focus range, and a third layer associated with the background.
 2. Themethod of claim 1, wherein determining the depth of focus rangecomprises: receiving user input defining the maximum depth of focus; andreceiving user input defining the minimum depth of focus.
 3. The methodof claim 6, wherein identifying the multiple layers comprises:converting maximum and minimum depths of focus into maximum and minimumdisparities; generating a circle of confusion (CoC) curve based on themaximum and minimum disparities; and identifying the multiple layersbased on different portions of the CoC curve.
 4. The method of claim 1,wherein: the first layer is associated with a portion of the CoC curveabove the maximum disparity; the second layer is associated with aportion of the CoC curve between the maximum and minimum disparities;and the third layer is associated with a portion of the CoC curve belowthe minimum disparity.
 5. The method of claim 1, wherein blending thelayers comprises: blending the third layer with the second layer using afirst blending map to produce blended image data; and blending theblended image data with the first layer using a second blending map. 6.A method comprising: determining, using at least one processor, a depthof focus range for a scene; determining, using the at least oneprocessor, multiple layers associated with the scene based on the depthof focus range, each layer associated with image data having a differentrange of disparity values; performing, using the at least one processor,one or more scattering operations on the image data using a kernel,wherein the kernel includes weights based on a circle of confusion (CoC)curve; and blending, using the at least one processor, the multiplelayers to produce an image having (i) a Bokeh effect in a foreground anda background and (ii) focused image data within the depth of focusrange; wherein the multiple layers include at least a first layerassociated with the foreground, a second layer associated with the depthof focus range, and a third layer associated with the background.
 7. Themethod of claim 6, wherein: the CoC curve includes multiple segments;and the weights of the kernel vary based on the segment associated withthe image data.
 8. An electronic device comprising: multiple imagesensors configured to capture image data for a scene; and at least oneprocessor operatively connected to the image sensors and configured to:determine a depth of focus range for the scene; determine multiplelayers associated with the scene based on the depth of focus range, eachlayer associated with image data having a different range of disparityvalues, wherein, to determine the multiple layers, the at least oneprocessor is configured to (i) convert maximum and minimum depths offocus into maximum and minimum disparities, (ii) generate a circle ofconfusion (CoC) curve based on the maximum and minimum disparities, and(iii) identify the multiple layers based on different portions of theCoC curve; and blend the layers to produce an image having (i) a Bokeheffect in a foreground and a background and (ii) focused image datawithin the depth of focus range, wherein the multiple layers include atleast a first layer associated with the foreground, a second layerassociated with the depth of focus range, and a third layer associatedwith the background.
 9. The electronic device of claim 8, wherein, todetermine the depth of focus range, the at least one processor isconfigured to: receive user input defining the maximum depth of focus;and receive user input defining the minimum depth of focus.
 10. Theelectronic device of claim 13, wherein, to identify the multiple layers,the at least one processor is configured to: convert maximum and minimumdepths of focus into maximum and minimum disparities; generate a circleof confusion (CoC) curve based on the maximum and minimum disparities;and identify the multiple layers based on different portions of the CoCcurve.
 11. The electronic device of claim 8, wherein: the first layer isassociated with a portion of the CoC curve above the maximum disparity;the second layer is associated with a portion of the CoC curve betweenthe maximum and minimum disparities; and the third layer is associatedwith a portion of the CoC curve below the minimum disparity.
 12. Theelectronic device of claim 8, wherein, to blend the layers, the at leastone processor is configured to: blend the third layer with the secondlayer using a first blending map to produce blended image data; andblend the blended image data with the first layer using a secondblending map.
 13. An electronic device comprising: multiple imagesensors configured to capture image data for a scene; and at least oneprocessor operatively connected to the image sensors and configured to:determine a depth of focus range for the scene; determine multiplelayers associated with the scene based on the depth of focus range, eachlayer associated with image data having a different range of disparityvalues; perform one or more scattering operations on the image datausing a kernel, wherein the kernel includes weights based on a circle ofconfusion (CoC) curve; and blend the multiple layers to produce an imagehaving (i) a Bokeh effect in a foreground and a background and (ii)focused image data within the depth of focus range; wherein the multiplelayers include at least a first layer associated with the foreground, asecond layer associated with the depth of focus range, and a third layerassociated with the background.
 14. The electronic device of claim 13,wherein: the CoC curve includes multiple segments; and the weights ofthe kernel vary based on the segment associated with the image data. 15.A non-transitory machine-readable medium containing instructions thatwhen executed cause at least one processor of an electronic device to:determine a depth of focus range for a scene; determine multiple layersassociated with the scene based on the depth of focus range, each layerassociated with image data having a different range of disparity values,wherein the instructions that when executed cause the at least oneprocessor to determine the multiple layers comprise instructions thatwhen executed cause the at least one processor to (i) convert maximumand minimum depths of focus into maximum and minimum disparities, (ii)generate a circle of confusion (CoC) curve based on the maximum andminimum disparities, and (iii) identify the multiple layers based ondifferent portions of the CoC curve; and blend the layers to produce animage having Lu a Bokeh effect in a foreground and a background and (ii)focused image data within the depth of focus range, wherein the multiplelayers include at least a first layer associated with the foreground, asecond layer associated with the depth of focus range, and a third layerassociated with the background.
 16. The non-transitory machine-readablemedium of claim 15, wherein the instructions that when executed causethe at least one processor to determine the depth of focus rangecomprise: instructions that when executed cause the at least oneprocessor to: receive user input defining the maximum depth of focus;and receive user input defining the minimum depth of focus.
 17. Thenon-transitory machine-readable medium of claim 20, wherein theinstructions that when executed cause the at least one processor toidentify the multiple layers comprise: instructions that when executedcause the at least one processor to: convert maximum and minimum depthsof focus into maximum and minimum disparities; generate a circle ofconfusion (CoC) curve based on the maximum and minimum disparities; andidentify the multiple layers based on different portions of the CoCcurve.
 18. The non-transitory machine-readable medium of claim 15,wherein: the first layer is associated with a portion of the CoC curveabove the maximum disparity; the second layer is associated with aportion of the CoC curve between the maximum and minimum disparities;and the third layer is associated with a portion of the CoC curve belowthe minimum disparity.
 19. The non-transitory machine-readable medium ofclaim 15, wherein the instructions that when executed cause the at leastone processor to blend the layers comprise: instructions that whenexecuted cause the at least one processor to: blend the third layer withthe second layer using a first blending map to produce blended imagedata; and blend the blended image data with the first layer using asecond blending map.
 20. A non-transitory machine-readable mediumcontaining instructions that when executed cause at least one processorto: determine a depth of focus range for a scene; determine multiplelayers associated with the scene based on the depth of focus range, eachlayer associated with image data having a different range of disparityvalues; perform one or more scattering operations on the image datausing a kernel, wherein the kernel includes weights based on a circle ofconfusion (CoC) curve; and blend the multiple layers to produce an imagehaving (i) a Bokeh effect in a foreground and a background and (ii)focused image data within the depth of focus range; wherein the multiplelayers include at least a first layer associated with the foreground, asecond layer associated with the depth of focus range, and a third layerassociated with the background.
 21. A method comprising: determining,using at least one processor, a focus position in a scene based on aninput touch point; determining, using the at least one processor, anobject class based on the input touch point; initializing, using the atleast one processor, a depth of focus range related to the input touchpoint, wherein initializing the depth of focus range is based on apredetermined thickness of the object class; and generating, using theat least one processor, an image preview based on the initial depth offocus range, the image preview being focused within the initial depth offocus range and blurry outside the initial depth of focus range.
 22. Themethod of claim 21, further comprising: receiving user input related tothe image preview, the user input accepting the initial depth of focusrange; and using the initial depth of focus range to generate a Bokehimage.
 23. The method of claim 21, further comprising: receiving userinput related to the image preview, the user input altering at least oneof a maximum depth of focus or a minimum depth of focus to define anrevised depth of focus range; and generating, using the at least oneprocessor, an updated image preview based on the revised depth of focusrange.
 24. The method of claim 21 wherein different object classes areassociated with different predetermined thicknesses, the differentobject classes including people, vehicles, trees, animals, and foodobject classes.